class Solution {
public:
    string solve(string s, string t) {
        int carry = 0;
        int pre = s.size() - 1;
        int suf = t.size() - 1;
        string result;
        while (pre >= 0 && suf >= 0)
        {
            int left = s[pre] - '0';
            int right = t[suf] - '0';
            int con = left + right + carry;
            carry = con / 10;
            int rem = con % 10;
            result.push_back('0' + rem);
            pre--;
            suf--;
        }
        while (pre >= 0)
        {
            int left = s[pre] - '0';
            int con = left + carry;
            carry = con / 10;
            int rem = con % 10;
            result.push_back('0' + rem);
            pre--;
        }
        while (suf >= 0)
        {
            int left = t[suf] - '0';
            int con = left + carry;
            carry = con / 10;
            int rem = con % 10;
            result.push_back('0' + rem);
            suf--;
        }
        if (carry == 1)
            result.push_back('1');
        std::reverse(result.begin(), result.end());
        return result;
    }
};